| Conditions | 6 |
| Total Lines | 24 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | class Validate { |
||
| 10 | sourceConfiguration (input, callback) { |
||
| 11 | let error = null |
||
| 12 | |||
| 13 | if (!input.source.url) { |
||
| 14 | if (!error) { |
||
| 15 | error = new Error('URL for MQTT broker has not been set.') |
||
| 16 | } |
||
| 17 | } |
||
| 18 | |||
| 19 | if (!this.url(input.source.url)) { |
||
| 20 | if (!error) { |
||
| 21 | error = new Error('Your defined URL is invalid. It should start with mqtt://') |
||
| 22 | } |
||
| 23 | } |
||
| 24 | |||
| 25 | let port = Number.parseInt(input.source.port) |
||
| 26 | if (Number.isNaN(port)) { |
||
| 27 | input.source.port = 1883 |
||
| 28 | } else { |
||
| 29 | input.source.port = port |
||
| 30 | } |
||
| 31 | |||
| 32 | callback(input, error) |
||
| 33 | } |
||
| 34 | |||
| 67 |